package com.fx.service.impl;

import cn.hutool.core.date.DateUtil;
import com.fx.entity.AdminTempUser;
import com.fx.entity.CustomerConfig;
import com.fx.entity.SysUser;
import com.fx.mapper.CustomerConfigMapper;
import com.fx.service.CustomerConfigService;
import com.fx.util.IdWorker;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class CustomerConfigServiceImpl implements CustomerConfigService {
    @Autowired
    private CustomerConfigMapper customerConfigMapper;
    @Autowired
    private IdWorker idWorker;

    @Override
    public CustomerConfig getById(String flId) {
        return customerConfigMapper.getById(flId);
    }

    @Override
    public List<CustomerConfig> getList(Map<String, Object> map) {
        return customerConfigMapper.queryList(map);
    }

    @Override
    public int getCount(Map<String, Object> map) {
        return customerConfigMapper.queryCount(map);
    }

    @Override
    public int save(CustomerConfig customerConfig) {
        customerConfig.setFlId(String.valueOf(idWorker.nextId()));
        customerConfig.setFlCreatedTime(DateUtil.now());
        customerConfig.setFlCreator(((AdminTempUser) SecurityUtils.getSubject().getPrincipal()).getFlName());
        return customerConfigMapper.save(customerConfig);
    }

    @Override
    public int updateById(CustomerConfig customerConfig) {
        return customerConfigMapper.updateById(customerConfig);
    }

    @Override
    public int remove(String flId) {
        return customerConfigMapper.remove(flId);
    }

    @Override
    public int batchRemove(String[] flIds) {
        return customerConfigMapper.batchRemove(flIds);
    }

}
